<!--suppress ALL-->
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="utf-8">
        <title>layuiAdmin 网站用户 iframe 框</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport"
              content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
        <link id="layuicss-layer" rel="stylesheet"
              href="https://www.layui.com/admin/std/dist/layuiadmin/layui/css/modules/layer/default/layer.css?v=3.1.1"
              media="all">
    </head>
    <body layadmin-themealias="default">

        <form class="layui-form">
            <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin"
                 style="padding: 20px 0 0 0;">
                <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            一级菜单
                        </div>
                        <div class="layui-inline">
                            <select name="parentId" lay-filter="LAY-role-role-type">
                                <option value="-1">请选择菜单</option>
                                <option th:each="menu : ${menuList}" th:value="${menu.id}"
                                        th:text="${menu.getMenuName()}">
                                </option>
                            </select>
                        </div>

                        <div class="layui-inline">
                            <label class="layui-form-label">菜单名:</label>
                            <div class="layui-input-block">
                                <input type="text" name="menuName" placeholder="请输入" autocomplete="off"
                                       class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">菜单路径:</label>
                            <div class="layui-input-block">
                                <input type="text" name="url" placeholder="请输入" autocomplete="off" class="layui-input">
                            </div>
                        </div>


                        <!--  <div class="layui-form-item">
                              <label class="layui-form-label">角色权限:</label>
                              <div class="layui-input-block" th:each="menu : ${menuList}">
                                  <input type="checkbox" name="roles" th:title="${menu.menuName}" th:value="${menu.id}">
                              </div>
                          </div>-->

                        <!-- <div class="layui-form-item">
                             <label class="layui-form-label">开关-默认开</label>
                             <div class="layui-input-block">
                                 <input type="checkbox" checked="" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="ON|OFF">
                             </div>
                         </div>-->
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
        <script src="/layuiadmin/layui/layui.js"></script>
        <script th:inline="none">
            //添加数据功能
            layui.use(['form', 'layer', 'jquery'], function () {
                var form = layui.form
                    , layer = layui.layer
                    , $ = layui.jquery,
                    table = layui.table
                //监听提交
                form.on('submit(formDemo)', function (data) {

                    //获取checkbox[name='like']的值
                    /* var arr = new Array();
                     $("input:checkbox[name='roles']:checked").each(function(i){
                         arr[i] = $(this).val();
                     });
                     data.field.like = arr.join(",");//将数组合并成字符串*/
                    $.ajax({
                        url: '/addMenu',
                        type: 'POST',
                        dataType: 'json',
                        data: {
                            menuName: data.field.menuName,
                            url: data.field.url,
                            parentId: data.field.parentId
                        },
                        success: function (msg) {
                            var returnCode = msg.code;
                            if (returnCode === 200) {
                                layer.closeAll('loading');
                                layer.load(2);
                                layer.msg("添加成功", {icon: 6});
                                setTimeout(function () {
                                    window.parent.location.reload();//修改成功后刷新父界面
                                }, 1000);
                                //加载层-风格

                            } else {
                                layer.msg("已经存在该设备,不支持重复添加", {icon: 5});
                            }
                        }
                    })
                    return false;
                });
            });
        </script>
        <style id="LAY_layadmin_theme">.layui-side-menu, .layadmin-pagetabs .layui-tab-title li:after, .layadmin-pagetabs .layui-tab-title li.layui-this:after, .layui-layer-admin .layui-layer-title, .layadmin-side-shrink .layui-side-menu .layui-nav > .layui-nav-item > .layui-nav-child {
            background-color: #20222A !important;
        }

        .layui-nav-tree .layui-this, .layui-nav-tree .layui-this > a, .layui-nav-tree .layui-nav-child dd.layui-this, .layui-nav-tree .layui-nav-child dd.layui-this a {
            background-color: #009688 !important;
        }

        .layui-layout-admin .layui-logo {
            background-color: #20222A !important;
        }</style>
    </body>
</html>